home *** CD-ROM | disk | FTP | other *** search
- Path: sun001.spd.dsccc.com!jmccarty
- From: jmccarty@sun1307.spd.dsccc.com (Mike McCarty)
- Newsgroups: comp.lang.c
- Subject: Re: Opening STDOUT As BINARY
- Date: 4 Apr 1996 22:16:46 GMT
- Organization: DSC Communications Corporation
- Message-ID: <4k1hoe$hn0@sun001.spd.dsccc.com>
- References: <3161CAD8.296C@netrover.com>
- NNTP-Posting-Host: sun1307.spd.dsccc.com
-
- In article <3161CAD8.296C@netrover.com>,
- Stephane Charette <charrick@netrover.com> wrote:
- )I've come across a problem, and I believe that it is
- )caused by limitations in C/C++. Can anyone help on the
- )following:
- )
- )I need to output binary information to the console, which
- )is then redirected to a file by the o/s. At the moment,
- )I'm using printf( "%c", mychar ) to output the the binary
- )data one character at a time as it comes in.
- )
- )However, it seems that the character #7 (0x07, bell) gets
- )sent to stdout followed by an automatic CR (0x0A). Every
- )other character in the ASCII table works fine! Is there
- )a way to reopen stdout in binary mode instead of as a text
- )stream? The extra 0x0A characters are corrupting the data!
- )
- )I've also tried "cout" and "putc", but they yield the same
- )result.
- )
- )Why do I need this: this application runs as a CGI-BIN,
- )and the web server EXPECTS the output to be sent to
- )stdout. I cannot fwrite() this information to a physical
- )file since the web server is capturing the console output!
- )
- )Thanks for any help,
- )
- )Stephane Charette.
-
-
- The behavior you describe has -nothing- to do with C. It has to do with
- the peculiarities of the operating system you are using. Is htis DOS? If
- so, then investigate putting stdout in binary mode. Your compiler should
- have a way to do this. Look into variables such as _fmode, __mode etc.
-
- Mike
- --
- ----
- char *p="char *p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
-
- I don't speak for DSC. <- They make me say that.
-